<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2022/8/16 0016
 * Time: 14:44
 */

namespace app\common\http\middleware;

class Auth
{

    public function handler($request, $next)
    {
        // 中间件前置部分
        //write_log($arr, 'auth', 'middleware');

        $arr = ["name" => "bqs", "age" => 55, "is_login" => 1];
        $preFileName = date('Ymd', time());
        $path = "logs/temp/" . date('Ym', time()) . '/';
        if (!is_dir($path)) {
            mkdir($path, 0755, true);
        }
        $ext = '.log';
        $filePath = $path . $preFileName . $ext;
        $content = var_export($arr, true);
        $tmp = "\n\n================= " . date('Y-m-d H:i:s') . " ===================\n\n";
        $content = $tmp . $content;

        file_put_contents($filePath, $content);
        // 中间件前置结束

        return $next($request);
    }

}